package codewars.arrays;

/**
 * Money, Money, Money
 * CodeWars: https://www.codewars.com/kata/money-money-money/java
 *
 * 存款计算，没什么难度
 * Created by yzy on 2019-05-07 17:25
 */
public class MoneyMoneyMoney {

    public static void main(String[] args) {
        System.out.println(calculateYears(1000,0.01625,0.18,1200));
    }


    public static int calculateYears(double principal, double interest,  double tax, double desired) {
        int years = 0;
        while(desired > principal){
            years++;
            principal += principal * interest * (1-tax);
        }
        return years;
    }
}
